package com.imist.nettybasic4.server.handler;

import com.imist.nettybasic4.protocol.request.HeartBeatRequestPacket;
import com.imist.nettybasic4.protocol.response.HeartBeatResponsePacket;
import com.imist.nettybasic4.protocol.response.LogoutResponsePacket;
import com.imist.nettybasic4.utils.SessionUtils;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.time.LocalDateTime;

@ChannelHandler.Sharable
public class HeartbeatRequestHandler extends SimpleChannelInboundHandler<HeartBeatRequestPacket> {
    public static final HeartbeatRequestHandler INSTANCE = new HeartbeatRequestHandler();

    private HeartbeatRequestHandler() {
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, HeartBeatRequestPacket heartBeatRequestPacket) throws Exception {
        System.out.println("服务端响应心跳:"+ LocalDateTime.now().toString());
        channelHandlerContext.writeAndFlush(new HeartBeatResponsePacket());
    }
}
